<!--
 * @Author: your name
 * @Date: 2021-10-12 11:12:43
 * @LastEditTime: 2021-10-19 13:49:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /a1902-a-group/admin_pc/src/views/Home/index.vue
-->
<template>
  <div>
    <el-button type="primary" @click="logins">点击</el-button>
    <el-button type="primary" @click="userLogin">登陆</el-button>
    <button @click="gets">获取</button>
    {{ user.name }}

    <el-button type="primary" @click="$router.push('/editor')">新增</el-button> 
    <el-button type="primary" @click="$router.push('/editor?id=123')">编辑</el-button> 


    <!-- <Test name='张三' age="123"/>
    <Son v-model.uppercase="str"/> -->
    <!-- <MyTeleport />

    {{myNames}}


    <button @click="upname">添加</button> -->
    <!-- <MyMixin /> -->

    <NewData />
  </div>
</template>

<script>
import { postHttp } from "../../utils/http";
import { login, getUsers } from "../../api/home";
import { mapActions, mapState } from "vuex";
import axios from "axios";
import Test from '../../component/Test.vue'
import Son from '../../component/Son.vue'
import MyTeleport from '../../component/MyTeleport.vue'
import MyMixin from '../../component/MyMixin.vue'
import NewData from '../../component/NewData.vue'
export default {
  data() {
    return {
      count: 0,
      counts: 1,
      str: 'a'
    };
  },
  created() {
    // axios.post('http://127.0.0.1:7001/list', {name: '小明'}).then(res => {
    //     console.log(res)
    // })

    axios.delete("http://127.0.0.1:7001/list/0").then((res) => {
      console.log(res);
    });

    axios.get("http://127.0.0.1:7001/list").then((res) => {
      console.log(res);
    });
    // 初始化数据
    // this.http();
  },
  computed: {
    ...mapState(["user"])
  },
  components: {
    Test,
    Son,
    MyTeleport,
    MyMixin,
    NewData
  },
  methods: {
    ...mapActions(["ACTION_LOGIN"]),

    async userLogin() {
      // const data = await postHttp('/login', {username: '123', passwrod: '123'});
      // console.log(data)
      this.ACTION_LOGIN();
    },

    // 登陆接口调用
    async logins() {
      this.ACTION_LOGIN();
      // const data = await login('https://creationapi.shbwyz.com/api/auth/login',  {
      //     name: 'zxd',
      //     password: 'zxd'
      // })
      // console.log(data);
    },
    // 获取用户信息
    async gets() {},

    // async http () {
    //     const data = await postHttp('https://creationapi.shbwyz.com/api/auth/login', {
    //         name: 'zxd',
    //         password: 'zxd'
    //     })
    // }
  },
};
</script>

<style>
</style>